﻿

#include "zyGroupBox.h"
#include <uxtheme.h>
#pragma comment(lib, "UxTheme.lib")
DarkMoonUI::zyGroupBox::zyGroupBox()
{
	SetMember(L"this", (LONG_PTR)this);
	m_obj->setWndProc(zyGroupBox_WndProc);
	SetMember(L"SystemTheme", 1);
}
DarkMoonUI::zyGroupBox::~zyGroupBox()
{

}

LRESULT WINAPI DarkMoonUI::zyGroupBox::zyGroupBox_WndProc(zyObject* obj, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL* bHandled)
{
	if (uMsg == WM_ERASEBKGND) {
		HBRUSH hBrush = (HBRUSH)obj->getPtrData(L"BackBrush");
		if (hBrush && hBrush != GetStockObject(NULL_BRUSH)) {
			RECT rect;
			GetClientRect(hWnd, &rect);
			FillRect((HDC)wParam, &rect, hBrush);
			*bHandled = TRUE;
			return 1;
		}
	}
	return zyCommandCtrol::zyCommand_WndProc(obj, hWnd, uMsg, wParam, lParam, bHandled);
}

BOOL DarkMoonUI::zyGroupBox::创建(HWND 参数_父窗口, const std::wstring& 参数_标题, POINT 参数_位置, POINT 参数_尺寸, int 参数_ID, int 参数_窗口风格, int 参数_扩展风格)
{
	if (参数_窗口风格 == 0)
		参数_窗口风格 = BS_GROUPBOX;
	if (参数_ID == NULL)
		参数_ID = 黑月默认ID();
	BOOL ret =_CreateCtrol(参数_父窗口, 参数_标题, 参数_位置, 参数_尺寸, 参数_ID, 参数_窗口风格, 参数_扩展风格 | WS_EX_CONTROLPARENT, L"Button");
	if (ret) {
		背景色(GetSysColor(COLOR_BTNFACE));
		if (GetMember(L"SystemTheme"))
			SetWindowTheme(取窗口句柄(), 0, 0);
	}
	return ret;
}

BOOL DarkMoonUI::zyGroupBox::创建(zyWindow& 参数_父窗口, const std::wstring& 参数_标题, POINT 参数_位置, POINT 参数_尺寸, int 参数_ID, int 参数_窗口风格, int 参数_扩展风格)
{
	if (参数_窗口风格 == 0)
		参数_窗口风格 = BS_GROUPBOX;
	if (参数_ID == NULL)
		参数_ID = 黑月默认ID();
	BOOL ret = _CreateCtrol(参数_父窗口.getHwnd(), 参数_标题, 参数_位置, 参数_尺寸, 参数_ID, 参数_窗口风格, 参数_扩展风格 | WS_EX_CONTROLPARENT, L"Button");
	if (ret) {
		背景色(GetSysColor(COLOR_BTNFACE));
		if (GetMember(L"SystemTheme"))
			SetWindowTheme(取窗口句柄(), 0, 0);
	}
	return ret;
}
std::wstring DarkMoonUI::zyGroupBox::标题(const std::wstring& 参数_标题) {
	if (参数_标题.empty()) {
		return 取文本();
	}
	else {
		置文本(参数_标题);
		return L"";
	}
}
BOOL DarkMoonUI::zyGroupBox::系统主题(BOOL 参数_系统主题) {
	int SystemTheme = (int)(INT_PTR)GetMember(L"SystemTheme");
	SetMember(L"SystemTheme", 参数_系统主题);
	return SystemTheme != 0;
}